package com.bwie.controller;

import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 牛毅
 * @version 1.0
 * @date 2025/7/18
 * @description TODO
 */
@RestController
@RequestMapping("/user/index")
@Slf4j
public class UserController {

    @Autowired
    TbUserService tbUserService;


    /**
     * @description: 发送短信验证码
     * @param: mobile
     * @return: com.bwie.utils.R
     * @author 牛毅
     * @date: 2025/7/18 14:26
     */
    @PostMapping("/sendCode/{mobile}")
    public R sendCode(@PathVariable("mobile") String mobile){
        return tbUserService.sendCode(mobile);
    }

    /**
     * @description: 注册
     * @param: null
     * @return:
     * @author 牛毅
     * @date: 2025/7/18 14:32
     */
    @PostMapping("/userReg")
    public R userReg(@RequestBody @Validated UserVo userVo){
        return tbUserService.userReg(userVo);
    }

    /**
     * @description: 登录
     * @param: null
     * @return:
     * @author 牛毅
     * @date: 2025/7/18 14:27
     */
    @PostMapping("/login")
    public R login(@RequestBody @Validated UserVo userVo){
        return tbUserService.login(userVo);
    }

    /**
     * @description: 获取菜单树
     * @param: null
     * @return:
     * @author 牛毅
     * @date: 2025/7/18 19:35
     */
    @PostMapping("/getTreeMenu")
    public R getTreeMenu(){
        return tbUserService.getTreeMenu();
    }

    /**
     * @description: 获取角色
     * @param: null
     * @return:
     * @author 牛毅
     * @date: 2025/7/20 19:27
     */
    @PostMapping("/getRoleByUserId")
    public R getRoleByUserId(){
        return tbUserService.getRoleByUserId();
    }
}
